package nlppatents.util;

//import java.util.ArrayList;
import java.util.HashMap;

public class DictWord //implements Comparable<DictWord>
{
	public static HashMap<String, DictWord> dictionary;
	public static final int INITIAL_WORDS_CAPACITY = 500000; 
	
	public static void init()
	{
		dictionary = new HashMap<String, DictWord>(INITIAL_WORDS_CAPACITY);
	}
	
	public static DictWord get(String word)
	{
		DictWord d = dictionary.get(word);
		if(d == null)
		{
			d = new DictWord(word);
			dictionary.put(word, d);
		}
		return d;
	}
	
	public String word;
	public int freq;
	public int coloc;
	
	//public int patentCount;
	//public Patent lastPatent;
	
	//public ArrayList<POSWord> posWords;
	
	public DictWord(String word)
	{
		this.word = word;
		freq = 0;
		//coloc = 0;
		
		//posWords = new ArrayList<POSWord>(1);
		
		// used for measurments
		//patentCount = 0;
		//lastPatent = null;
	}

	/*
	 * Added so that DictWords could be stuffed into TreeMaps and TreeSets. 
	 * word is guaranteed to be unique.
	 */
	/*@Override
	public int compareTo(DictWord o) 
	{
		if(this == o)
			return 0;
		// hopefully trying the hashes codes first speeds up comparison
		int myHash = word.hashCode();
		int oHash = o.hashCode();
		if(myHash < oHash)
			return -1;
		else if(myHash > oHash)
			return 1;
		return word.compareTo(o.word);
	}
	*/
	/*
	public void add(POSWord p)
	{
		posWords.add(p);
		// IMPORTANT!  We have a ton of words, so I don't want to waste any space on excess elements
		posWords.trimToSize();
	}
	*/
}
